﻿package mortal.game.view.mainUI.Navbar
{
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.core.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.player.info.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.groupCopy.view.*;
    import mortal.game.view.vip.*;
    import mortal.mvc.core.*;

    public class NavbarCopyIcon extends NavbarBaseIcon
    {
        private var _numBg:GBitmap;
        private var _leftEnterNum:GTextFiled;

        public function NavbarCopyIcon()
        {
            return;
        }// end function

        override protected function addListerner() : void
        {
            super.addListerner();
            Cache.instance.role.roleEntityInfo.addEventListener(EntityInfoEventName.UpdateLevel, this.showLeftEnterNum);
            NetDispatcher.addCmdListener(ServerCommand.CopyEnterTimesUpdate, this.showLeftEnterNum);
            NetDispatcher.addCmdListener(ServerCommand.VipLevelUp, this.showLeftEnterNum);
            return;
        }// end function

        override protected function configUI() : void
        {
            super.configUI();
            this.showLeftEnterNum();
            return;
        }// end function

        private function showLeftEnterNum(param1:Object = null) : void
        {
            var _loc_2:int = 0;
            if (GameController.autoGuide.hasGuideGroupCopy())
            {
                _loc_2 = _loc_2 + (3 - Cache.instance.copy.getGroupCopyEnterNum(ECopyType._ECopyTypeTeam));
            }
            if (GameController.autoGuide.hasGuideCopyIcon())
            {
                _loc_2 = _loc_2 + (3 - Cache.instance.copy.getGroupCopyEnterNum(ECopyType._ECopyTypeSingle));
            }
            if (GameDefConfig.instance.getSystemOpenLevel(49))
            {
                _loc_2 = _loc_2 + VipUtil.vipCopyLeftNum;
            }
            if (GameController.autoGuide.hasGuideDefenseCopy())
            {
                _loc_2 = _loc_2 + (1 - Cache.instance.copy.getTodayEnterTimes(112));
            }
            if (GameController.autoGuide.hasTeamGuideDefenseCopy())
            {
                _loc_2 = _loc_2 + (1 - Cache.instance.copy.getTodayEnterTimes(GroupCopyGroupDefensePanel.GroupDefenCopyId));
            }
            if (_loc_2 > 0)
            {
                if (this._numBg == null)
                {
                    this._numBg = GlobalClass.getBitmap(ImagesConst.NumberBg);
                    this._numBg.x = 20;
                    this._numBg.y = 0;
                    this.addChild(this._numBg);
                }
                if (this._leftEnterNum == null)
                {
                    this._leftEnterNum = UIFactory.gTextField("", 22, 1, 20, 20, this, GlobalStyle.textFormatBai.center());
                    this._leftEnterNum.mouseEnabled = false;
                }
                this._leftEnterNum.text = _loc_2.toString();
            }
            else
            {
                if (this._leftEnterNum)
                {
                    this._leftEnterNum.dispose();
                    this._leftEnterNum = null;
                }
                if (this._numBg)
                {
                    this._numBg.dispose();
                    this._numBg = null;
                }
            }
            return;
        }// end function

    }
}
